/*
 * Tencent is pleased to support the open source community by making
 * 蓝鲸智云 - 配置平台 (BlueKing - Configuration System) available.
 * Copyright (C) 2017 Tencent. All rights reserved.
 * Licensed under the MIT License (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at http://opensource.org/licenses/MIT
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 * We undertake not to change the open source license (MIT license) applicable
 * to the current version of the project delivered to anyone in the future.
 */

package bsrelation

/*
  Biz set relation event is a mix event of cc_ApplicationBase and cc_BizSetBase events. It's a combination of these two
  kinds of events. It has these features as follows:
  1. It's a virtual event of the relationship between biz set and biz, generated from the events mentioned upper.
  2. Biz set and biz events are converted to biz set relation event and stored in chain node with instance id being the
    biz set id. Biz set event has the biz set id in it, while biz event gets related biz set id by searching all of the
    biz sets to find those with the changed attributes in their "bk_scope" field. We do not really care about the order
    of these events in a batch operation, and the same biz set relation events(with the same biz set id) are aggregated
    to only one event in a batch operation.
  3. Biz set relation event has a event detail in the form of {"bk_biz_set_id": 1, "bk_biz_ids": [1 ,2]}. It contains
    the ID of the biz set whose relation is changed and all of the biz IDs it involves after the change. The detail is
    generated by the biz set id as the chain node instance id and the biz ids are searched in db by biz set scope.
  4. Biz set relation has a different watch token data structure with the other resources in flow.
  5. Only changes that results in changes of the relationship between biz set and biz will trigger a biz set relation
    event, otherwise, this event will be skipped. Which means it will be triggered when biz set is added, deleted or
    updated with its "bk_scope" field. And when biz is added, deleted or updated with an attribute that is in related
    biz set's "bk_scope" field.
  6. Biz set relation's auth resource is redirect to biz set resource, and it's event is authorized by biz set event.
*/
